<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>apt-cyg安装 | 个人博客 | 一个coder的成长记录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="cygwin">
    <meta name="description" content="apt-cyg 因为使用在windows下使用cygwin，为了方便安装其它包，所以需要安装apt-cyg包管理器。  使用setup-x86_64.exe安装（apt-cyg） setup-x86_64.exe已经是cygwin的包管理器，所以其它包都可以通过它来安装。   别名是为了方便使用，设置只在当前的shell生效 alias cyg-get=”/cygdrive/d/path/to/c">
<meta name="keywords" content="cygwin">
<meta property="og:type" content="article">
<meta property="og:title" content="apt-cyg安装">
<meta property="og:url" content="https://betgar.github.io/2018/06/04/apt-cyg/index.html">
<meta property="og:site_name" content="个人博客">
<meta property="og:description" content="apt-cyg 因为使用在windows下使用cygwin，为了方便安装其它包，所以需要安装apt-cyg包管理器。  使用setup-x86_64.exe安装（apt-cyg） setup-x86_64.exe已经是cygwin的包管理器，所以其它包都可以通过它来安装。   别名是为了方便使用，设置只在当前的shell生效 alias cyg-get=”/cygdrive/d/path/to/c">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-04-12T09:42:14.470Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="apt-cyg安装">
<meta name="twitter:description" content="apt-cyg 因为使用在windows下使用cygwin，为了方便安装其它包，所以需要安装apt-cyg包管理器。  使用setup-x86_64.exe安装（apt-cyg） setup-x86_64.exe已经是cygwin的包管理器，所以其它包都可以通过它来安装。   别名是为了方便使用，设置只在当前的shell生效 alias cyg-get=”/cygdrive/d/path/to/c">
    
        <link rel="alternate" type="application/atom+xml" title="个人博客" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide">
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">俊男</h5>
          <a href="mailto:betgar@163.com" title="betgar@163.com" class="mail">betgar@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/">
                <i class="icon icon-lg icon-home"></i>
                Home
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives">
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags">
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories">
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/betgar" target="_blank">
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://weibo.com/u/2296734915" target="_blank">
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/about">
                <i class="icon icon-lg icon-link"></i>
                About
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">apt-cyg安装</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">apt-cyg安装</h1>
        <h5 class="subtitle">
            
                <time datetime="2018-06-04T00:29:00.000Z" itemprop="datePublished" class="page-time">
  2018-06-04
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/cygwin/">cygwin</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#apt-cyg"><span class="post-toc-number">1.</span> <span class="post-toc-text">apt-cyg</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#使用setup-x86-64-exe安装（apt-cyg）"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">使用setup-x86_64.exe安装（apt-cyg）</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#安装wget"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">安装wget</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#下载apt-cyg"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">下载apt-cyg</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#设置镜像源"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">设置镜像源</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#安装chere的package"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">安装chere的package</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#apt-cyg源码"><span class="post-toc-number">1.6.</span> <span class="post-toc-text">apt-cyg源码</span></a></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-apt-cyg" class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">apt-cyg安装</h1>
        <div class="post-meta">
            <time class="post-time" title="2018-06-04 08:29:00" datetime="2018-06-04T00:29:00.000Z" itemprop="datePublished">2018-06-04</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/cygwin/">cygwin</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style="display:none">
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h1 id="apt-cyg"><a href="#apt-cyg" class="headerlink" title="apt-cyg"></a>apt-cyg</h1><blockquote>
<p>因为使用在windows下使用<code>cygwin</code>，为了方便安装其它包，所以需要安装<code>apt-cyg</code>包管理器。</p>
</blockquote>
<h2 id="使用setup-x86-64-exe安装（apt-cyg）"><a href="#使用setup-x86-64-exe安装（apt-cyg）" class="headerlink" title="使用setup-x86_64.exe安装（apt-cyg）"></a>使用setup-x86_64.exe安装（apt-cyg）</h2><blockquote>
<p><code>setup-x86_64.exe</code>已经是<code>cygwin</code>的包管理器，所以其它包都可以通过它来安装。</p>
</blockquote>
<p> <del>别名是为了方便使用，设置只在当前的shell生效</del><br> <del>alias cyg-get=”/cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P”</del><br> <del>建议使用<a href="ftp://sourceware.org/pub/cygwin镜像比较快" target="_blank" rel="noopener">ftp://sourceware.org/pub/cygwin镜像比较快</a></del><br> <del><a href="http://mirrors.163.com/cygwin/" target="_blank" rel="noopener">http://mirrors.163.com/cygwin/</a></del><br><del>cyg-get wget</del></p>
<h2 id="安装wget"><a href="#安装wget" class="headerlink" title="安装wget"></a>安装wget</h2><blockquote>
<p>使用<code>apt-cyg</code>需要先安装<code>wget</code></p>
</blockquote>
<h2 id="下载apt-cyg"><a href="#下载apt-cyg" class="headerlink" title="下载apt-cyg"></a>下载<code>apt-cyg</code></h2><blockquote>
<p>下载<code>apt-cyg</code>保存到<code>$root\cygwin64\bin</code></p>
<p>地址：<a href="https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg" target="_blank" rel="noopener">https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg</a></p>
</blockquote>
<h2 id="设置镜像源"><a href="#设置镜像源" class="headerlink" title="设置镜像源"></a>设置镜像源</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 添加权限</span></span><br><span class="line">chmod +x  /bin/apt-cyg</span><br><span class="line"><span class="comment"># 设置官方镜像</span></span><br><span class="line">apt-cyg mirror ftp://sourceware.org/pub/cygwin</span><br></pre></td></tr></table></figure>
<h2 id="安装chere的package"><a href="#安装chere的package" class="headerlink" title="安装chere的package"></a>安装<code>chere</code>的package</h2><blockquote>
<p><code>chere</code>可以把<code>cygwin</code>添加到<strong>资源管理器的右键菜单</strong>(windows explorer context menu)</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 安装chere</span></span><br><span class="line">apy-cyg install chere</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 注册到context menu</span></span><br><span class="line">chere -i -t mintty -s bash</span><br><span class="line"><span class="meta">#</span><span class="bash"> windows context menu 有Bash Prompt here</span></span><br></pre></td></tr></table></figure>
<h2 id="apt-cyg源码"><a href="#apt-cyg源码" class="headerlink" title="apt-cyg源码"></a>apt-cyg源码</h2><blockquote>
<p>如果apt-cyg安装不成功，直接copy下文源码保存apt-cyg文件，放到cygwin的安装目录的bin下，添加一下执行权限（如果需要）。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br><span class="line">586</span><br><span class="line">587</span><br><span class="line">588</span><br><span class="line">589</span><br><span class="line">590</span><br><span class="line">591</span><br><span class="line">592</span><br><span class="line">593</span><br><span class="line">594</span><br><span class="line">595</span><br><span class="line">596</span><br><span class="line">597</span><br><span class="line">598</span><br><span class="line">599</span><br><span class="line">600</span><br><span class="line">601</span><br><span class="line">602</span><br><span class="line">603</span><br><span class="line">604</span><br><span class="line">605</span><br><span class="line">606</span><br><span class="line">607</span><br><span class="line">608</span><br><span class="line">609</span><br><span class="line">610</span><br><span class="line">611</span><br><span class="line">612</span><br><span class="line">613</span><br><span class="line">614</span><br><span class="line">615</span><br><span class="line">616</span><br><span class="line">617</span><br><span class="line">618</span><br><span class="line">619</span><br><span class="line">620</span><br><span class="line">621</span><br><span class="line">622</span><br><span class="line">623</span><br><span class="line">624</span><br><span class="line">625</span><br><span class="line">626</span><br><span class="line">627</span><br><span class="line">628</span><br><span class="line">629</span><br><span class="line">630</span><br><span class="line">631</span><br><span class="line">632</span><br><span class="line">633</span><br><span class="line">634</span><br><span class="line">635</span><br><span class="line">636</span><br><span class="line">637</span><br><span class="line">638</span><br><span class="line">639</span><br><span class="line">640</span><br><span class="line">641</span><br><span class="line">642</span><br><span class="line">643</span><br><span class="line">644</span><br><span class="line">645</span><br><span class="line">646</span><br><span class="line">647</span><br><span class="line">648</span><br><span class="line">649</span><br><span class="line">650</span><br><span class="line">651</span><br><span class="line">652</span><br><span class="line">653</span><br><span class="line">654</span><br><span class="line">655</span><br><span class="line">656</span><br><span class="line">657</span><br><span class="line">658</span><br><span class="line">659</span><br><span class="line">660</span><br><span class="line">661</span><br><span class="line">662</span><br><span class="line">663</span><br><span class="line">664</span><br><span class="line">665</span><br><span class="line">666</span><br><span class="line">667</span><br><span class="line">668</span><br><span class="line">669</span><br><span class="line">670</span><br><span class="line">671</span><br><span class="line">672</span><br><span class="line">673</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="comment"># apt-cyg: install tool for Cygwin similar to debian apt-get</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># The MIT License (MIT)</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Copyright (c) 2013 Trans-code Design</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Permission is hereby granted, free of charge, to any person obtaining a copy</span></span><br><span class="line"><span class="comment"># of this software and associated documentation files (the "Software"), to deal</span></span><br><span class="line"><span class="comment"># in the Software without restriction, including without limitation the rights</span></span><br><span class="line"><span class="comment"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span></span><br><span class="line"><span class="comment"># copies of the Software, and to permit persons to whom the Software is</span></span><br><span class="line"><span class="comment"># furnished to do so, subject to the following conditions:</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># The above copyright notice and this permission notice shall be included in</span></span><br><span class="line"><span class="comment"># all copies or substantial portions of the Software.</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></span><br><span class="line"><span class="comment"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></span><br><span class="line"><span class="comment"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></span><br><span class="line"><span class="comment"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></span><br><span class="line"><span class="comment"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span></span><br><span class="line"><span class="comment"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span></span><br><span class="line"><span class="comment"># THE SOFTWARE.</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> [ <span class="variable">$&#123;BASH_VERSINFO&#125;</span><span class="variable">$&#123;BASH_VERSINFO[1]&#125;</span> -lt 42 ]</span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">  <span class="built_in">echo</span> <span class="string">'Bash version 4.2+ required'</span></span><br><span class="line">  <span class="built_in">exit</span></span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">usage=<span class="string">"\</span></span><br><span class="line"><span class="string">NAME</span></span><br><span class="line"><span class="string">  apt-cyg - package manager utility</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">SYNOPSIS</span></span><br><span class="line"><span class="string">  apt-cyg [operation] [options] [targets]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">DESCRIPTION</span></span><br><span class="line"><span class="string">  apt-cyg is a package management utility that tracks installed packages on a</span></span><br><span class="line"><span class="string">  Cygwin system. Invoking apt-cyg involves specifying an operation with any</span></span><br><span class="line"><span class="string">  potential options and targets to operate on. A target is usually a package</span></span><br><span class="line"><span class="string">  name, file name, URL, or a search string. Targets can be provided as command</span></span><br><span class="line"><span class="string">  line arguments.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">OPERATIONS</span></span><br><span class="line"><span class="string">  install</span></span><br><span class="line"><span class="string">    Install package(s).</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  remove</span></span><br><span class="line"><span class="string">    Remove package(s) from the system.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  update</span></span><br><span class="line"><span class="string">    Download a fresh copy of the master package list (setup.ini) from the</span></span><br><span class="line"><span class="string">    server defined in setup.rc.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  download</span></span><br><span class="line"><span class="string">    Retrieve package(s) from the server, but do not install/upgrade anything.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  show</span></span><br><span class="line"><span class="string">    Display information on given package(s).</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  depends</span></span><br><span class="line"><span class="string">    Produce a dependency tree for a package.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  rdepends</span></span><br><span class="line"><span class="string">    Produce a tree of packages that depend on the named package.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  list</span></span><br><span class="line"><span class="string">    Search each locally-installed package for names that match regexp. If no</span></span><br><span class="line"><span class="string">    package names are provided in the command line, all installed packages will</span></span><br><span class="line"><span class="string">    be queried.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  listall</span></span><br><span class="line"><span class="string">    This will search each package in the master package list (setup.ini) for</span></span><br><span class="line"><span class="string">    names that match regexp.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  category</span></span><br><span class="line"><span class="string">    Display all packages that are members of a named category.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  listfiles</span></span><br><span class="line"><span class="string">    List all files owned by a given package. Multiple packages can be specified</span></span><br><span class="line"><span class="string">    on the command line.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  search</span></span><br><span class="line"><span class="string">    Search for downloaded packages that own the specified file(s). The path can</span></span><br><span class="line"><span class="string">    be relative or absolute, and one or more files can be specified.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  searchall</span></span><br><span class="line"><span class="string">    Search cygwin.com to retrieve file information about packages. The provided</span></span><br><span class="line"><span class="string">    target is considered to be a filename and searchall will return the</span></span><br><span class="line"><span class="string">    package(s) which contain this file.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  mirror</span></span><br><span class="line"><span class="string">    Set the mirror; a full URL to a location where the database, packages, and</span></span><br><span class="line"><span class="string">    signatures for this repository can be found. If no URL is provided, display</span></span><br><span class="line"><span class="string">    current mirror.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  cache</span></span><br><span class="line"><span class="string">    Set the package cache directory. If a file is not found in cache directory,</span></span><br><span class="line"><span class="string">    it will be downloaded. Unix and Windows forms are accepted, as well as</span></span><br><span class="line"><span class="string">    absolute or regular paths. If no directory is provided, display current</span></span><br><span class="line"><span class="string">    cache.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">OPTIONS</span></span><br><span class="line"><span class="string">  --nodeps</span></span><br><span class="line"><span class="string">    Specify this option to skip all dependency checks.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  --version</span></span><br><span class="line"><span class="string">    Display version and exit.</span></span><br><span class="line"><span class="string">"</span></span><br><span class="line"></span><br><span class="line">version=<span class="string">"\</span></span><br><span class="line"><span class="string">apt-cyg version 1</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">The MIT License (MIT)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">Copyright (c) 2005-9 Stephen Jungels</span></span><br><span class="line"><span class="string">"</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> wget &#123;</span><br><span class="line">  <span class="keyword">if</span> <span class="built_in">command</span> wget -h &amp;&gt;/dev/null</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">command</span> wget <span class="string">"<span class="variable">$@</span>"</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    warn wget is not installed, using lynx as fallback</span><br><span class="line">    <span class="built_in">set</span> <span class="string">"<span class="variable">$&#123;*: -1&#125;</span>"</span></span><br><span class="line">    lynx -<span class="built_in">source</span> <span class="string">"<span class="variable">$1</span>"</span> &gt; <span class="string">"<span class="variable">$&#123;1##*/&#125;</span>"</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> find-workspace &#123;</span><br><span class="line">  <span class="comment"># default working directory and mirror</span></span><br><span class="line">  </span><br><span class="line">  <span class="comment"># work wherever setup worked last, if possible</span></span><br><span class="line">  cache=$(awk <span class="string">'</span></span><br><span class="line"><span class="string">  BEGIN &#123;</span></span><br><span class="line"><span class="string">    RS = "\n\\&lt;"</span></span><br><span class="line"><span class="string">    FS = "\n\t"</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  $1 == "last-cache" &#123;</span></span><br><span class="line"><span class="string">    print $2</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  '</span> /etc/setup/setup.rc)</span><br><span class="line"></span><br><span class="line">  mirror=$(awk <span class="string">'</span></span><br><span class="line"><span class="string">  /last-mirror/ &#123;</span></span><br><span class="line"><span class="string">    getline</span></span><br><span class="line"><span class="string">    print $1</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  '</span> /etc/setup/setup.rc)</span><br><span class="line">  mirrordir=$(sed <span class="string">'</span></span><br><span class="line"><span class="string">  s / %2f g</span></span><br><span class="line"><span class="string">  s : %3a g</span></span><br><span class="line"><span class="string">  '</span> &lt;&lt;&lt; <span class="string">"<span class="variable">$mirror</span>"</span>)</span><br><span class="line"></span><br><span class="line">  mkdir -p <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$arch</span>"</span></span><br><span class="line">  <span class="built_in">cd</span> <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$arch</span>"</span></span><br><span class="line">  <span class="keyword">if</span> [ -e setup.ini ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">return</span> 0</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    get-setup</span><br><span class="line">    <span class="built_in">return</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> get-setup &#123;</span><br><span class="line">  touch setup.ini</span><br><span class="line">  mv setup.ini setup.ini-save</span><br><span class="line">  wget -N <span class="variable">$mirror</span>/<span class="variable">$arch</span>/setup.bz2</span><br><span class="line">  <span class="keyword">if</span> [ -e setup.bz2 ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    bunzip2 setup.bz2</span><br><span class="line">    mv setup setup.ini</span><br><span class="line">    <span class="built_in">echo</span> Updated setup.ini</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    <span class="built_in">echo</span> Error updating setup.ini, reverting</span><br><span class="line">    mv setup.ini-save setup.ini</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> check-packages &#123;</span><br><span class="line">  <span class="keyword">if</span> [[ <span class="variable">$pks</span> ]]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">return</span> 0</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    <span class="built_in">echo</span> No packages found.</span><br><span class="line">    <span class="built_in">return</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> warn &#123;</span><br><span class="line">  <span class="built_in">printf</span> <span class="string">'\e[1;31m%s\e[m\n'</span> <span class="string">"$*"</span> &gt;&amp;2</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-update &#123;</span><br><span class="line">  <span class="keyword">if</span> find-workspace</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    get-setup</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-category &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    $1 == "@" &#123;</span></span><br><span class="line"><span class="string">      pck = $2</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    $1 == "category:" &amp;&amp; $0 ~ query &#123;</span></span><br><span class="line"><span class="string">      print pck</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> query=<span class="string">"<span class="variable">$pks</span>"</span> setup.ini</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-list &#123;</span><br><span class="line">  <span class="built_in">local</span> sbq</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">let</span> sbq++ &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">    awk <span class="string">'NR&gt;1 &amp;&amp; $1~pkg &amp;&amp; $0=$1'</span> pkg=<span class="string">"<span class="variable">$pkg</span>"</span> /etc/setup/installed.db</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">  <span class="built_in">let</span> sbq &amp;&amp; <span class="built_in">return</span></span><br><span class="line">  awk <span class="string">'NR&gt;1 &amp;&amp; $0=$1'</span> /etc/setup/installed.db</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-listall &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="built_in">local</span> sbq</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">let</span> sbq++ &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">    awk <span class="string">'$1~pkg &amp;&amp; $0=$1'</span> RS=<span class="string">'\n\n@ '</span> FS=<span class="string">'\n'</span> pkg=<span class="string">"<span class="variable">$pkg</span>"</span> setup.ini</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-listfiles &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="built_in">local</span> pkg sbq</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    (( sbq++ )) &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">    <span class="keyword">if</span> [ ! -e /etc/setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz ]</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">      download <span class="string">"<span class="variable">$pkg</span>"</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    gzip -<span class="built_in">cd</span> /etc/setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-show &#123;</span><br><span class="line">  find-workspace</span><br><span class="line">  check-packages</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    (( notfirst++ )) &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    $1 == query &#123;</span></span><br><span class="line"><span class="string">      print</span></span><br><span class="line"><span class="string">      fd++</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    END &#123;</span></span><br><span class="line"><span class="string">      if (! fd)</span></span><br><span class="line"><span class="string">        print "Unable to locate package " query</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> RS=<span class="string">'\n\n@ '</span> FS=<span class="string">'\n'</span> query=<span class="string">"<span class="variable">$pkg</span>"</span> setup.ini</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-depends &#123;</span><br><span class="line">  find-workspace</span><br><span class="line">  check-packages</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    @include "join"</span></span><br><span class="line"><span class="string">    $1 == "@" &#123;</span></span><br><span class="line"><span class="string">      apg = $2</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    $1 == "requires:" &#123;</span></span><br><span class="line"><span class="string">      for (z=2; z&lt;=NF; z++)</span></span><br><span class="line"><span class="string">        reqs[apg][z-1] = $z</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    END &#123;</span></span><br><span class="line"><span class="string">      prpg(ENVIRON["pkg"])</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    function smartmatch(small, large,    values) &#123;</span></span><br><span class="line"><span class="string">      for (each in large)</span></span><br><span class="line"><span class="string">        values[large[each]]</span></span><br><span class="line"><span class="string">      return small in values</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    function prpg(fpg) &#123;</span></span><br><span class="line"><span class="string">      if (smartmatch(fpg, spath)) return</span></span><br><span class="line"><span class="string">      spath[length(spath)+1] = fpg</span></span><br><span class="line"><span class="string">      print join(spath, 1, length(spath), " &gt; ")</span></span><br><span class="line"><span class="string">      if (isarray(reqs[fpg]))</span></span><br><span class="line"><span class="string">        for (each in reqs[fpg])</span></span><br><span class="line"><span class="string">          prpg(reqs[fpg][each])</span></span><br><span class="line"><span class="string">      delete spath[length(spath)]</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> setup.ini</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-rdepends &#123;</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    @include "join"</span></span><br><span class="line"><span class="string">    $1 == "@" &#123;</span></span><br><span class="line"><span class="string">      apg = $2</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    $1 == "requires:" &#123;</span></span><br><span class="line"><span class="string">      for (z=2; z&lt;=NF; z++)</span></span><br><span class="line"><span class="string">        reqs[$z][length(reqs[$z])+1] = apg</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    END &#123;</span></span><br><span class="line"><span class="string">      prpg(ENVIRON["pkg"])</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    function smartmatch(small, large,    values) &#123;</span></span><br><span class="line"><span class="string">      for (each in large)</span></span><br><span class="line"><span class="string">        values[large[each]]</span></span><br><span class="line"><span class="string">      return small in values</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    function prpg(fpg) &#123;</span></span><br><span class="line"><span class="string">      if (smartmatch(fpg, spath)) return</span></span><br><span class="line"><span class="string">      spath[length(spath)+1] = fpg</span></span><br><span class="line"><span class="string">      print join(spath, 1, length(spath), " &lt; ")</span></span><br><span class="line"><span class="string">      if (isarray(reqs[fpg]))</span></span><br><span class="line"><span class="string">        for (each in reqs[fpg])</span></span><br><span class="line"><span class="string">          prpg(reqs[fpg][each])</span></span><br><span class="line"><span class="string">      delete spath[length(spath)]</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> setup.ini</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-download &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="built_in">local</span> pkg sbq</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    (( sbq++ )) &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">    download <span class="string">"<span class="variable">$pkg</span>"</span></span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> download &#123;</span><br><span class="line">  <span class="built_in">local</span> pkg digest digactual</span><br><span class="line">  pkg=<span class="variable">$1</span></span><br><span class="line">  <span class="comment"># look for package and save desc file</span></span><br><span class="line"></span><br><span class="line">  awk <span class="string">'$1 == pc'</span> RS=<span class="string">'\n\n@ '</span> FS=<span class="string">'\n'</span> pc=<span class="variable">$pkg</span> setup.ini &gt; desc</span><br><span class="line">  <span class="keyword">if</span> [ ! -s desc ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> Unable to locate package <span class="variable">$pkg</span></span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># download and unpack the bz2 or xz file</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># pick the latest version, which comes first</span></span><br><span class="line">  <span class="built_in">set</span> -- $(awk <span class="string">'$1 == "install:"'</span> desc)</span><br><span class="line">  <span class="keyword">if</span> (( ! <span class="variable">$#</span> ))</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> <span class="string">'Could not find "install" in package description: obsolete package?'</span></span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  dn=$(dirname <span class="variable">$2</span>)</span><br><span class="line">  bn=$(basename <span class="variable">$2</span>)</span><br><span class="line"></span><br><span class="line">  <span class="comment"># check the md5</span></span><br><span class="line">  digest=<span class="variable">$4</span></span><br><span class="line">  <span class="keyword">case</span> <span class="variable">$&#123;#digest&#125;</span> <span class="keyword">in</span></span><br><span class="line">   32) <span class="built_in">hash</span>=md5sum    ;;</span><br><span class="line">  128) <span class="built_in">hash</span>=sha512sum ;;</span><br><span class="line">  <span class="keyword">esac</span></span><br><span class="line">  mkdir -p <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$dn</span>"</span></span><br><span class="line">  <span class="built_in">cd</span> <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$dn</span>"</span></span><br><span class="line">  <span class="keyword">if</span> ! <span class="built_in">test</span> -e <span class="variable">$bn</span> || ! <span class="variable">$hash</span> -c &lt;&lt;&lt; <span class="string">"<span class="variable">$digest</span> <span class="variable">$bn</span>"</span></span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    wget -O <span class="variable">$bn</span> <span class="variable">$mirror</span>/<span class="variable">$dn</span>/<span class="variable">$bn</span></span><br><span class="line">    <span class="variable">$hash</span> -c &lt;&lt;&lt; <span class="string">"<span class="variable">$digest</span> <span class="variable">$bn</span>"</span> || <span class="built_in">exit</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  tar tf <span class="variable">$bn</span> | gzip &gt; /etc/setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz</span><br><span class="line">  <span class="built_in">cd</span> ~-</span><br><span class="line">  mv desc <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$dn</span>"</span></span><br><span class="line">  <span class="built_in">echo</span> <span class="variable">$dn</span> <span class="variable">$bn</span> &gt; /tmp/dwn</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-search &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  <span class="built_in">echo</span> Searching downloaded packages...</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    key=$(<span class="built_in">type</span> -P <span class="string">"<span class="variable">$pkg</span>"</span> | sed s./..)</span><br><span class="line">    [[ <span class="variable">$key</span> ]] || key=<span class="variable">$pkg</span></span><br><span class="line">    <span class="keyword">for</span> manifest <span class="keyword">in</span> /etc/setup/*.lst.gz</span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">      <span class="keyword">if</span> gzip -<span class="built_in">cd</span> <span class="variable">$manifest</span> | grep -q <span class="string">"<span class="variable">$key</span>"</span></span><br><span class="line">      <span class="keyword">then</span></span><br><span class="line">        package=$(sed <span class="string">'</span></span><br><span class="line"><span class="string">        s,/etc/setup/,,</span></span><br><span class="line"><span class="string">        s,.lst.gz,,</span></span><br><span class="line"><span class="string">        '</span> &lt;&lt;&lt; <span class="variable">$manifest</span>)</span><br><span class="line">        <span class="built_in">echo</span> <span class="variable">$package</span></span><br><span class="line">      <span class="keyword">fi</span></span><br><span class="line">    <span class="keyword">done</span></span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-searchall &#123;</span><br><span class="line">  <span class="built_in">cd</span> /tmp</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">printf</span> -v qs <span class="string">'text=1&amp;arch=%s&amp;grep=%s'</span> <span class="variable">$arch</span> <span class="string">"<span class="variable">$pkg</span>"</span></span><br><span class="line">    wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?<span class="string">"<span class="variable">$qs</span>"</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    NR == 1 &#123;next&#125;</span></span><br><span class="line"><span class="string">    mc[$1]++ &#123;next&#125;</span></span><br><span class="line"><span class="string">    /-debuginfo-/ &#123;next&#125;</span></span><br><span class="line"><span class="string">    /^cygwin32-/ &#123;next&#125;</span></span><br><span class="line"><span class="string">    &#123;print $1&#125;</span></span><br><span class="line"><span class="string">    '</span> FS=-[[:digit:]] matches</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-install &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  find-workspace</span><br><span class="line">  <span class="built_in">local</span> pkg dn bn requires wr package sbq script</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> grep -q <span class="string">"^<span class="variable">$pkg</span> "</span> /etc/setup/installed.db</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> Package <span class="variable">$pkg</span> is already installed, skipping</span><br><span class="line">    <span class="built_in">continue</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  (( sbq++ )) &amp;&amp; <span class="built_in">echo</span></span><br><span class="line">  <span class="built_in">echo</span> Installing <span class="variable">$pkg</span></span><br><span class="line"></span><br><span class="line">  download <span class="variable">$pkg</span></span><br><span class="line">  <span class="built_in">read</span> dn bn &lt;/tmp/dwn</span><br><span class="line">  <span class="built_in">echo</span> Unpacking...</span><br><span class="line"></span><br><span class="line">  <span class="built_in">cd</span> <span class="string">"<span class="variable">$cache</span>/<span class="variable">$mirrordir</span>/<span class="variable">$dn</span>"</span></span><br><span class="line">  tar -x -C / -f <span class="variable">$bn</span></span><br><span class="line">  <span class="comment"># update the package database</span></span><br><span class="line"></span><br><span class="line">  awk <span class="string">'</span></span><br><span class="line"><span class="string">  ins != 1 &amp;&amp; pkg &lt; $1 &#123;</span></span><br><span class="line"><span class="string">    print pkg, bz, 0</span></span><br><span class="line"><span class="string">    ins = 1</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  1</span></span><br><span class="line"><span class="string">  END &#123;</span></span><br><span class="line"><span class="string">    if (ins != 1) print pkg, bz, 0</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  '</span> pkg=<span class="string">"<span class="variable">$pkg</span>"</span> bz=<span class="variable">$bn</span> /etc/setup/installed.db &gt; /tmp/awk.$$</span><br><span class="line">  mv /etc/setup/installed.db /etc/setup/installed.db-save</span><br><span class="line">  mv /tmp/awk.$$ /etc/setup/installed.db</span><br><span class="line"></span><br><span class="line">  [ -v nodeps ] &amp;&amp; <span class="built_in">continue</span></span><br><span class="line">  <span class="comment"># recursively install required packages</span></span><br><span class="line"></span><br><span class="line">  requires=$(awk <span class="string">'$1=="requires", $0=$2'</span> FS=<span class="string">': '</span> desc)</span><br><span class="line">  <span class="built_in">cd</span> ~-</span><br><span class="line">  wr=0</span><br><span class="line">  <span class="keyword">if</span> [[ <span class="variable">$requires</span> ]]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> Package <span class="variable">$pkg</span> requires the following packages, installing:</span><br><span class="line">    <span class="built_in">echo</span> <span class="variable">$requires</span></span><br><span class="line">    <span class="keyword">for</span> package <span class="keyword">in</span> <span class="variable">$requires</span></span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">      <span class="keyword">if</span> grep -q <span class="string">"^<span class="variable">$package</span> "</span> /etc/setup/installed.db</span><br><span class="line">      <span class="keyword">then</span></span><br><span class="line">        <span class="built_in">echo</span> Package <span class="variable">$package</span> is already installed, skipping</span><br><span class="line">        <span class="built_in">continue</span></span><br><span class="line">      <span class="keyword">fi</span></span><br><span class="line">      apt-cyg install --noscripts <span class="variable">$package</span> || (( wr++ ))</span><br><span class="line">    <span class="keyword">done</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">if</span> (( wr ))</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> some required packages did not install, continuing</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># run all postinstall scripts</span></span><br><span class="line"></span><br><span class="line">  [ -v noscripts ] &amp;&amp; <span class="built_in">continue</span></span><br><span class="line">  find /etc/postinstall -name <span class="string">'*.sh'</span> | <span class="keyword">while</span> <span class="built_in">read</span> script</span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">echo</span> Running <span class="variable">$script</span></span><br><span class="line">    <span class="variable">$script</span></span><br><span class="line">    mv <span class="variable">$script</span> <span class="variable">$script</span>.<span class="keyword">done</span></span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">  <span class="built_in">echo</span> Package <span class="variable">$pkg</span> installed</span><br><span class="line"></span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-remove &#123;</span><br><span class="line">  check-packages</span><br><span class="line">  <span class="built_in">cd</span> /etc</span><br><span class="line">  cygcheck awk bash bunzip2 grep gzip mv sed tar xz &gt; setup/essential.lst</span><br><span class="line">  <span class="keyword">for</span> pkg <span class="keyword">in</span> <span class="string">"<span class="variable">$&#123;pks[@]&#125;</span>"</span></span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> ! grep -q <span class="string">"^<span class="variable">$pkg</span> "</span> setup/installed.db</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> Package <span class="variable">$pkg</span> is not installed, skipping</span><br><span class="line">    <span class="built_in">continue</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ ! -e setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    warn Package manifest missing, cannot remove <span class="variable">$pkg</span>. Exiting</span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  gzip -dk setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz</span><br><span class="line">  awk <span class="string">'</span></span><br><span class="line"><span class="string">  NR == FNR &#123;</span></span><br><span class="line"><span class="string">    if ($NF) ess[$NF]</span></span><br><span class="line"><span class="string">    next</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  $NF in ess &#123;</span></span><br><span class="line"><span class="string">    exit 1</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">  '</span> FS=<span class="string">'[/\\\\]'</span> setup/&#123;essential,<span class="variable">$pkg</span>&#125;.lst</span><br><span class="line">  esn=$?</span><br><span class="line">  <span class="keyword">if</span> [ <span class="variable">$esn</span> = 0 ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> Removing <span class="variable">$pkg</span></span><br><span class="line">    <span class="keyword">if</span> [ -e preremove/<span class="string">"<span class="variable">$pkg</span>"</span>.sh ]</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">      preremove/<span class="string">"<span class="variable">$pkg</span>"</span>.sh</span><br><span class="line">      rm preremove/<span class="string">"<span class="variable">$pkg</span>"</span>.sh</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    <span class="built_in">mapfile</span> dt &lt; setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst</span><br><span class="line">    <span class="keyword">for</span> each <span class="keyword">in</span> <span class="variable">$&#123;dt[*]&#125;</span></span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">      [ -f /<span class="variable">$each</span> ] &amp;&amp; rm /<span class="variable">$each</span></span><br><span class="line">    <span class="keyword">done</span></span><br><span class="line">    <span class="keyword">for</span> each <span class="keyword">in</span> <span class="variable">$&#123;dt[*]&#125;</span></span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">      [ -d /<span class="variable">$each</span> ] &amp;&amp; rmdir --i /<span class="variable">$each</span></span><br><span class="line">    <span class="keyword">done</span></span><br><span class="line">    rm -f setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst.gz postinstall/<span class="string">"<span class="variable">$pkg</span>"</span>.sh.done</span><br><span class="line">    awk -i inplace <span class="string">'$1 != ENVIRON["pkg"]'</span> setup/installed.db</span><br><span class="line">    <span class="built_in">echo</span> Package <span class="variable">$pkg</span> removed</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  rm setup/<span class="string">"<span class="variable">$pkg</span>"</span>.lst</span><br><span class="line">  <span class="keyword">if</span> [ <span class="variable">$esn</span> = 1 ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    warn apt-cyg cannot remove package <span class="variable">$pkg</span>, exiting</span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-mirror &#123;</span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">"<span class="variable">$pks</span>"</span> ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    awk -i inplace <span class="string">'</span></span><br><span class="line"><span class="string">    1</span></span><br><span class="line"><span class="string">    /last-mirror/ &#123;</span></span><br><span class="line"><span class="string">      getline</span></span><br><span class="line"><span class="string">      print "\t" pks</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> pks=<span class="string">"<span class="variable">$pks</span>"</span> /etc/setup/setup.rc</span><br><span class="line">    <span class="built_in">echo</span> Mirror <span class="built_in">set</span> to <span class="string">"<span class="variable">$pks</span>"</span>.</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    /last-mirror/ &#123;</span></span><br><span class="line"><span class="string">      getline</span></span><br><span class="line"><span class="string">      print $1</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> /etc/setup/setup.rc</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> apt-cache &#123;</span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">"<span class="variable">$pks</span>"</span> ]</span><br><span class="line">  <span class="keyword">then</span></span><br><span class="line">    vas=$(cygpath -aw <span class="string">"<span class="variable">$pks</span>"</span>)</span><br><span class="line">    awk -i inplace <span class="string">'</span></span><br><span class="line"><span class="string">    1</span></span><br><span class="line"><span class="string">    /last-cache/ &#123;</span></span><br><span class="line"><span class="string">      getline</span></span><br><span class="line"><span class="string">      print "\t" vas</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> vas=<span class="string">"<span class="variable">$&#123;vas//\\/\\\\&#125;</span>"</span> /etc/setup/setup.rc</span><br><span class="line">    <span class="built_in">echo</span> Cache <span class="built_in">set</span> to <span class="string">"<span class="variable">$vas</span>"</span>.</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    awk <span class="string">'</span></span><br><span class="line"><span class="string">    /last-cache/ &#123;</span></span><br><span class="line"><span class="string">      getline</span></span><br><span class="line"><span class="string">      print $1</span></span><br><span class="line"><span class="string">    &#125;</span></span><br><span class="line"><span class="string">    '</span> /etc/setup/setup.rc</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> [ -p /dev/stdin ]</span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">  <span class="built_in">mapfile</span> -t pks</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># process options</span></span><br><span class="line">until [ <span class="variable">$#</span> = 0 ]</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line">  <span class="keyword">case</span> <span class="string">"<span class="variable">$1</span>"</span> <span class="keyword">in</span></span><br><span class="line"></span><br><span class="line">    --nodeps)</span><br><span class="line">      nodeps=1</span><br><span class="line">      <span class="built_in">shift</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">    --noscripts)</span><br><span class="line">      noscripts=1</span><br><span class="line">      <span class="built_in">shift</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">    --version)</span><br><span class="line">      <span class="built_in">printf</span> <span class="string">"<span class="variable">$version</span>"</span></span><br><span class="line">      <span class="built_in">exit</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">    update)</span><br><span class="line">      <span class="built_in">command</span>=<span class="variable">$1</span></span><br><span class="line">      <span class="built_in">shift</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">    list | cache  | remove | depends | listall  | download | listfiles |\</span><br><span class="line">    show | mirror | search | install | category | rdepends | searchall )</span><br><span class="line">      <span class="keyword">if</span> [[ <span class="variable">$command</span> ]]</span><br><span class="line">      <span class="keyword">then</span></span><br><span class="line">        pks+=(<span class="string">"<span class="variable">$1</span>"</span>)</span><br><span class="line">      <span class="keyword">else</span></span><br><span class="line">        <span class="built_in">command</span>=<span class="variable">$1</span></span><br><span class="line">      <span class="keyword">fi</span></span><br><span class="line">      <span class="built_in">shift</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">    *)</span><br><span class="line">      pks+=(<span class="string">"<span class="variable">$1</span>"</span>)</span><br><span class="line">      <span class="built_in">shift</span></span><br><span class="line">    ;;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">esac</span></span><br><span class="line"><span class="keyword">done</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span> -a</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">type</span> -t apt-<span class="variable">$command</span> | grep -q <span class="keyword">function</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">  <span class="built_in">readonly</span> arch=<span class="variable">$&#123;HOSTTYPE/i6/x&#125;</span></span><br><span class="line">  apt-<span class="variable">$command</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">  <span class="built_in">printf</span> <span class="string">"<span class="variable">$usage</span>"</span></span><br><span class="line"><span class="keyword">fi</span></span><br></pre></td></tr></table></figure>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2019-04-12T09:42:14.470Z" itemprop="dateUpdated">2019-04-12 17:42:14</time>
</span><br>


        
        原文链接：<a href="/2018/06/04/apt-cyg/" target="_blank" rel="external">https://betgar.github.io/2018/06/04/apt-cyg/</a>
        
    </div>
    
    <footer>
        <a href="https://betgar.github.io">
            <img src="/img/avatar.jpg" alt="俊男">
            俊男
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/cygwin/">cygwin</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://betgar.github.io/2018/06/04/apt-cyg/&title=《apt-cyg安装》 — 个人博客&pic=https://betgar.github.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://betgar.github.io/2018/06/04/apt-cyg/&title=《apt-cyg安装》 — 个人博客&source=各种技术加身的coder" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://betgar.github.io/2018/06/04/apt-cyg/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《apt-cyg安装》 — 个人博客&url=https://betgar.github.io/2018/06/04/apt-cyg/&via=https://betgar.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://betgar.github.io/2018/06/04/apt-cyg/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2018/06/25/android-dev-env/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Android 开发环境部署</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2018/06/04/npm-common-commands/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">npm常用命令</h4>
      </a>
    </div>
  
</nav>



    











    <!-- Valine Comments -->
    <div class="comments vcomment" id="comments"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@latest/dist/Valine.min.js"></script>
    <!-- Valine Comments script -->
    <script>
        var GUEST_INFO = ['nick','mail','link'];
        var guest_info = 'nick,mail,link'.split(',').filter(function(item){
          return GUEST_INFO.indexOf(item) > -1
        });
        new Valine({
            el: '#comments',
            notify: 'false' == 'true',
            verify: 'false' == 'true',
            appId: "kiGWA9mdoVtQlfGYA5uDBNX7-gzGzoHsz",
            appKey: "dHCOdD0oEIjJd0cJoAHHN0y3",
            avatar: "mm",
            placeholder: "Just comment it",
            guest_info: guest_info.length == 0 ? GUEST_INFO : guest_info,
            pageSize: "10"
        })
    </script>
    <!-- Valine Comments end -->







</article>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>俊男 &copy; 2017 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://betgar.github.io/2018/06/04/apt-cyg/&title=《apt-cyg安装》 — 个人博客&pic=https://betgar.github.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://betgar.github.io/2018/06/04/apt-cyg/&title=《apt-cyg安装》 — 个人博客&source=各种技术加身的coder" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://betgar.github.io/2018/06/04/apt-cyg/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《apt-cyg安装》 — 个人博客&url=https://betgar.github.io/2018/06/04/apt-cyg/&via=https://betgar.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://betgar.github.io/2018/06/04/apt-cyg/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: false };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
